<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Subtract Avisynth Filter</title>
<link rel="stylesheet" type="text/css" href="../../avisynth.css">
</head>
<body>
<h2>
<a name="Subtract"></a>Subtract 
</h2>
<p><code>Subtract </code>(<var>clip1, clip2</var>)</p>
<p><code>Subtract</code> produces an output clip in which every pixel is set according 
  to the difference between the corresponding pixels in <i>clip1</i> and <i>clip2</i>. 
  More specifically, it sets each pixel to (50% gray) + (<i>clip1</i> pixel) - 
  (<i>clip2</i> pixel). You can use <tt><a href="levels.htm">Levels</a></tt> afterwards if you want to 
  increase the contrast.</p>
<p>Also see <a href="../syntax.htm#multiclip" target="_self">here</a> for the 
  resulting clip properties. </p>
<p><b>Examples:</b> </p>
      <pre># Make the differences between clip1 and clip2 blatantly obvious
Subtract(clip1, clip2).Levels(127, 1, 129, 0, 255)</pre>
      <p>If you want to see the deltas between adjacent frames in a single clip, 
        you can do it like this: </p>
      <pre>Subtract(clip.Trim(1,0), clip)</pre>
      
<p><b>About offset of luma range:</b></p>
      
<p>For YUV formats the valid Y range is from 16 to 235 inclusive and subtract takes this into account.
This means that the following script</p>
<pre>Subtract(any_clip, any_clip)</pre>
<p>will result in a grey clip with luma = 126. For those that require a subtract function for
pc_range YUV data use <a href="overlay.htm">Overlay</a>: </p>
<pre>#Overlay(any_clip, any_clip, mode=&quot;Difference&quot;, pc_range=true) # grey clip with luma = 128
Overlay(clip1, clip2, mode=&quot;Difference&quot;, pc_range=true)</pre>
      
<p><kbd>$Date: 2006/09/27 18:41:25 $</kbd></p>
<FORM>
<INPUT TYPE="Button" VALUE="Back"
onClick="history.go(-1)">
</form>
</body>
</html>
